package cn.bdqn.asecu.controller;

import cn.bdqn.asecu.service.ChatRoomService;
import cn.bdqn.pojo.ChatRoom;
import cn.bdqn.pojo.User;
import cn.bdqn.vo.UserChatRoom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class ChatRoomController {
    @Autowired
    ChatRoomService chatRoomService;

    @RequestMapping("chatroom")
    public String chatroom(){
        return "chatroom";
    }

    @RequestMapping("newTheme")
    public String newTheme(Model model){
        List<UserChatRoom> pro = chatRoomService.getPro();
        model.addAttribute("pro",pro);
        return "newTheme";
    }

    @RequestMapping("song")
    @ResponseBody
    public String song(HttpServletRequest request,Integer[] song,String content,String pj){
       User user= (User) request.getSession().getAttribute("user");
       chatRoomService.fasong(user.getId(),song,content);
        return "200";
    }

//    @RequestMapping("getPro")
//    public List<UserChatRoom> getPro(){
//
//    }
}
